<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<html lang="zh-CN">
<head>
    <%@include file="/resource/common/head.jsp" %>
</head>
<script>
    function refreshConfig(ip) {
        $("#refreshForm input[name='systemIp']").val(ip);
    }
</script>
<body>
<div id="wrapper">
    <%@include file="/resource/common/navigator.jsp" %>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">接入客户端列表</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                    </div>
                    <div class="panel-body">
                        <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                            <thead>
                            <tr>
                                <th>业务系统IP</th>
                                <th>首次接入时间</th>
                                <th>最近报告时间</th>
                                <th>当前状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:choose>
                                <c:when test="${!clientReportList.isEmpty()}">
                                    <c:forEach items="${clientReportList}" var="clientReport">
                                        <tr class="${currentTime.getTime()-clientReport.last_time.getTime()>1000*30?"danger":"success"}">
                                            <td>${clientReport.ip}</td>
                                            <td><fmt:formatDate value="${clientReport.first_time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                            <td><fmt:formatDate value="${clientReport.last_time}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                            <td>${currentTime.getTime()-clientReport.last_time.getTime()>1000*30?"异常":"正常"}</td>
                                            <td>
                                                <button title="刷新客户端缓存" class="btn btn-info" data-toggle="modal" data-target="#refreshModal"
                                                        onclick="refreshConfig('${clientReport.ip}')">
                                                    <i class="fa fa-refresh"></i>
                                                </button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </c:when>
                                <c:otherwise>
                                    <tr>
                                        <td colspan="5" align="center">暂无数据</td>
                                    </tr>
                                </c:otherwise>
                            </c:choose>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <%--删除配置弹框--%>
    <div class="modal fade" id="refreshModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="refreshModalLabel">刷新系统配置缓存</h4>
                </div>
                <form id="refreshForm" role="form" action="${basePath}/clients" method="post">
                    <div class="modal-body">
                        确定刷新该系统配置缓存吗?
                        <input type="hidden" name="systemIp">
                        <input type="hidden" name="operation" value="refresh">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="submit" class="btn btn-primary">确定</button>
                    </div>
                </form>
            </div>
            <!-- /.modal-content -->
        </div>
    </div>
</div>
<!-- 页面依赖js文件 -->
<%@include file="/resource/common/scripts.jsp" %>
</body>
</html>
